import { createRouter, createWebHistory } from 'vue-router'

const routes = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('../page/login/index.vue')
    },
    {
        path: '/home',
        name: 'home',
        component: () => import('../page/home/index.vue'),
        children: [
            {
                path: '',
                redirect: '/home/dashboard'
            },
            {
                path: 'dashboard',
                name: 'dashboard',
                component: () => import('../page/dashboard/index.vue')
            },
            // 后台管理
            {
                path: 'product-manage',
                name: 'product-manage',
                component: () => import('../page/admin/product-manage/index.vue')
            },
            {
                path: 'category-manage',
                name: 'category-manage',
                component: () => import('../page/admin/category-manage/index.vue')
            },
            {
                path: 'supplier-manage',
                name: 'supplier-manage',
                component: () => import('../page/admin/supplier-manage/index.vue')
            },
            {
                path: 'customer-manage',
                name: 'customer-manage',
                component: () => import('../page/admin/customer-manage/index.vue')
            },
            // 店铺经营
            {
                path: 'purchase',
                name: 'purchase',
                component: () => import('../page/business/purchase/index.vue')
            },
            {
                path: 'sales',
                name: 'sales',
                component: () => import('../page/business/sales/index.vue')
            },
            {
                path: 'inventory-adjust',
                name: 'inventory-adjust',
                component: () => import('../page/business/inventory-adjust/index.vue')
            },
            {
                path: 'other-cost',
                name: 'other-cost',
                component: () => import('../page/business/other-cost/index.vue')
            },
            {
                path: 'cost-adjust',
                name: 'cost-adjust',
                component: () => import('../page/business/cost-adjust/index.vue')
            },
            // 明细查询
            {
                path: 'profit-query',
                name: 'profit-query',
                component: () => import('../page/query/profit-query/index.vue')
            },
            {
                path: 'cost-query',
                name: 'cost-query',
                component: () => import('../page/query/cost-query/index.vue')
            },
            {
                path: 'gross-profit-query',
                name: 'gross-profit-query',
                component: () => import('../page/query/gross-profit-query/index.vue')
            },
            {
                path: 'inventory-query',
                name: 'inventory-query',
                component: () => import('../page/query/inventory-query/index.vue')
            },
            // 系统设置
            {
                path: 'system-setting',
                name: 'system-setting',
                component: () => import('../page/system-setting/index.vue')
            },
            // 空路由重定向
            {
                path: '/:pathMatch(.*)*',
                redirect: '/home/dashboard'
            }
        ]
    },
    {
        path: '/:pathMatch(.*)*',
        redirect: '/login'
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes
})

export default router